﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Layouts/List.Master" AutoEventWireup="true" CodeBehind="UserWfRole.aspx.cs" Inherits="Bingosoft.WebApp.Modules.SecurityConsole.User.UserWfRole" %>
<%@ Import Namespace="Bingosoft.Modules.SecurityConsole.Common.Helper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>用户流程角色维护</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
   <script type="text/javascript">
       var Global = {};
       Global.contextPath = '<%= RequestHelper.GetContextPath(Request) %>';
    </script>
    <div class="datalist">
        <!-- 标题头 -->        <h2 style="height: 30px;">
            流程角色信息列表
        </h2>
        <!-- 工具栏 -->
        <div class="toolbar" style="height: 30px;">
            <asp:LinkButton ID="addFunctionID" runat="server" OnClientClick="return addRolesForUser();"
                OnClick="SearchGrid">
                <span>
                    <img alt="" runat="server" id="img1" src="~/Images/icon_new.gif" style="border: 0px" />添加流程角色
                </span>
            </asp:LinkButton>
            <asp:LinkButton ID="LinkButton2" runat="server" OnClientClick="return removeRoles();"
                OnClick="RemoveRolesFromUser">
                <span>
                    <img id="Img2" alt="" runat="server" src="~/Images/ico_del.gif" style="border: 0px" />移除流程角色
                </span>
            </asp:LinkButton>
        </div>
        <div class="datagrid" style="clear: left;">
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="wfRoleId" DataSourceID="SmartDataSource1" PageSize="10">
                <Columns>
                    <asp:CheckBoxField DataField="wfRoleId" ItemStyle-HorizontalAlign="Center" />
                    <asp:BoundField DataField="RoleName" HeaderText="角色名称" SortExpression="RoleName"
                        ItemStyle-HorizontalAlign="Left" />
                          <asp:BoundField DataField="OrgName" HeaderText="组织名称" SortExpression="OrgName"
                        ItemStyle-HorizontalAlign="Left" />
                        <asp:BoundField DataField="TypeName" HeaderText="参与者类型" SortExpression="TypeName" />
                    <asp:BoundField DataField="ParticipantTypeName" HeaderText="流转角色" SortExpression="ParticipantTypeName" />
                   
                    <asp:BoundField DataField="description" HeaderText="角色说明" SortExpression="description"
                        ItemStyle-HorizontalAlign="Left" />
                    <asp:TemplateField HeaderText="操作">
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnDelete" runat="server" ToolTip="移除" ImageUrl="~/Images/ico_del.gif"
                                            _KeyId='<%#Eval("wfRoleId")%>' CausesValidation="False" OnClientClick="return window.confirm('您确认要移除该角色吗?')"
                                            OnClick="RemoveRoleFromUser"></asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <CheckBoxSettings Enabled="True" Position="0" />
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="user.user_wkrole_list"
                SelectCommandAutoPageWrap="true" DefaultSortExpression="wfRoleId ASC">
            </web:SmartSqlDataSource>
        </div>
    </div>
    <div class="itemdetail">
        <!-- 页脚区域 -->
        <div class="footer">
            <asp:Button ID="CloseButton2" runat="server" Text="关闭" OnClientClick="return closeDialog();" />
        </div>
    </div>
    <script type="text/javascript">
        var userId = '<%=Request.Params["UserId"] %>';

        function addRolesForUser() {
            var url = "OrgAndRoleAdd.aspx";
            var params = { title: "添加流程角色" };
            params.UserId = userId;
            var returnValue = showCenterModalDialog(buildUrl(url, params), 700, 200, null);
            return returnValue == "true";
        }


        function removeRoles() {
            var oSmartGridView1 = document.getElementById("<%=SmartGridView1.ClientID%>");
            var sValues = oSmartGridView1.control.getCheckedValues(true);

            if (sValues && sValues.length > 0) {
                if (window.confirm("您确认要删除所选的流程角色吗？")) {
                    return true;
                }
            }

            return false;
        }    
    </script>
</asp:Content>
